package com.zhenti.z1;

import java.util.Arrays;

public class zhenti_P4 {
    public static void main(String[] args) {
        int[][] cuts = {{1,2},{1,10},{2,10}};
        System.out.println(minCut(cuts));

    }
    public static long  minCut(int[][]  cuts){
        if (cuts == null || cuts.length == 0)
            return 1000L * 1000L * 1000L;
        Arrays.sort(cuts,(a,b)-> a[0] != b[0] ? a[0]-b[0] : a[1]-b[1]);
        int n = cuts.length;
        int pre = 0;
        int  xMaxDiff = 0;
        int i = 0;
        while (i < n && cuts[i][0] == 1){
            xMaxDiff = Math.max(xMaxDiff,cuts[i][1]-pre);
            pre = cuts[i][1];
            i++;
        }
        xMaxDiff = Math.max(xMaxDiff,10000-pre);

        pre=0;
        int yMaxDiff = 0;
        while (i<n && cuts[i][0] == 2){
            yMaxDiff = Math.max(yMaxDiff,cuts[i][1]-pre);
            pre = cuts[i][1];
            i++;
        }
        yMaxDiff = Math.max(yMaxDiff,10000-pre);
        pre = 0;
        int zMaxDiff = 0;
        while (i< n && cuts[i][0] == 3){
            zMaxDiff = Math.max(zMaxDiff,cuts[i][1]-pre);
            pre = cuts[i][1];
            i++;
        }
        zMaxDiff = Math.max(zMaxDiff,10000-pre);

        return (long)xMaxDiff * (long)yMaxDiff * (long)zMaxDiff;

    }
}
